package view;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Insets;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JToggleButton;
import model.Instrument;
import util.Images;
import view.tool.SequenceTool;

public class InstrumentButton extends JToggleButton {

	private SequenceTool sequenceTool;

	public InstrumentButton(Instrument instrument, SequenceTool sequenceTool) {
		this.sequenceTool = sequenceTool;
		this.setMargin(new Insets(1,1,1,1));
		this.setBorder(BorderFactory.createEmptyBorder());
		this.setPreferredSize(new Dimension(32,31));
		this.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));

		this.setActionCommand(instrument.toString());

		this.setIcon(new ImageIcon(
			Images.getInstrumentIcon(instrument)
		));
	}

	/**
	 * The SequenceTool corresponding to this button which allows the Sequence
	 * model relating to this instrument to be modified.
	 */
	public SequenceTool getSequenceTool() {
		return this.sequenceTool;
	}
}
